package com.lindroy.controller

import com.lindroy.config.RespResult
import com.lindroy.constants.HTTP_OK
import com.lindroy.constants.ResultMsg
import com.lindroy.service.DepartmentService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*

/**
 * @author Lin
 * @date 2019/10/15
 * @function
 * @Description
 */
@RestController
@RequestMapping("/department")
class DepartmentController {

    @Autowired
    lateinit var deptService:DepartmentService

    @GetMapping("/departments")
    fun findAll() = RespResult(HTTP_OK,ResultMsg.FIND_SUCCESS,deptService.findAll())

    @GetMapping("/departments/{id}")
    fun findById(@PathVariable(value = "id") id: Int) = RespResult(HTTP_OK,ResultMsg.FIND_SUCCESS,deptService.findById(id))

    @DeleteMapping("/departments/{id}")
    fun deleteById(@PathVariable(value = "id") id: Int)=RespResult(HTTP_OK,ResultMsg.DELETE_SUCCESS,deptService.deleteById(id))
}